package com.example.designpatterns.creational.singleton;

/**
 * @author zuitu@foxmail.com
 * @date 2024/1/18
 * 枚举
 */
public class EnumInner {
    //私有化构造函数
    private EnumInner() {
    }

    //定义一个静态枚举类
    enum SingletonEnum {
        //创建一个枚举对象，该对象天生为单例
        INSTANCE;
        private EnumInner enumInner;

        //私有化枚举的构造函数
        SingletonEnum() {
            enumInner = new EnumInner();
        }

        public EnumInner getInstnce() {
            return enumInner;
        }
    }

    //对外暴露一个获取User对象的静态方法
    public static EnumInner getInstance() {
        return SingletonEnum.INSTANCE.getInstnce();
    }
}
